package LeetCode;

import java.util.Scanner;

//
// Created by ✎﹏ℳ๓独赏☆独醉 on 2024/4/19.
// 
public class 最长回文子串 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str =scan.next();
        String temp = longestPalindrome(str);
        System.out.println(temp);
    }

    private static String longestPalindrome(String s) {
        String str = "";
        int max = 0;
        for (int i = 0; i < s.length(); i++) {
            int lpoint1 = i-1,rpoint1 = i+1,num1 = 1;
            while(lpoint1 >= 0 && rpoint1 < s.length()){
                if(s.charAt(lpoint1) == s.charAt(rpoint1)){
                    num1+=2;
                    lpoint1--;
                    rpoint1++;
                }else {
                    break;
                }
            }
            int lpoint2 = i,rpoint2 = i+1,num2=0;
            while(lpoint2 >= 0 && rpoint2< s.length()){
                if(s.charAt(lpoint2) == s.charAt(rpoint2)){
                    num2+=2;
                    lpoint2--;
                    rpoint2++;
                }else {
                    break;
                }
            }
            if(num1 > num2){
                if(max < num1){
                    max = num1;
                    str = s.substring(lpoint1+1,rpoint1);
                }
            }else {
                if(max < num2){
                    max = num2;
                    str = s.substring(lpoint2+1,rpoint2);
                }
            }
        }
        System.out.println(max);
        return str;
    }
}
